<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{bundle.branchcfg}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
        <h:form prependId="false">

           <script type="text/javascript">  
                function handleSaveRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgBranchcfg.hide();  
                    }  
                }
                
                function handleDeleteRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgDelBranchcfg.hide();  
                    }  
                }
                
                function componenKeyPress(e) {
                    var code = (e.keyCode ? e.keyCode : e.which);
                    if(code==13) {
                       cmdBranchcfg.jq.click();
                       e.preventDefault ? e.preventDefault() : e.returnValue = false;
                       e.stopPropagation();
                    }
                }
                
            </script>  

            <!--  -->
            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton value="#{bundle.btnNew}"
                                     icon="ui-icon-document"
                                     action="#{branchcfgBean.newData()}"  
                                     oncomplete="dlgBranchcfg.show()"
                                     rendered="#{ugpolicyBean.cekButtonAccess(182,'INS;')}"
                                     update="displayBranchcfg"> 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgBranchcfg.show()"
                                     icon="ui-icon-disk" 
                                     rendered="#{ugpolicyBean.cekButtonAccess(182,'OPN;')}"
                                     update="displayBranchcfg" > 
                    </p:commandButton>

                    <p:commandButton type="button" value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                     onclick="dlgDelBranchcfg.show()"
                                     rendered="#{ugpolicyBean.cekButtonAccess(182,'DEL;')}"
                                     update="displayBranchcfg" /> 

                    <!--p:commandButton type="push" value="#{bundle.btnPrint}" icon="ui-icon-print"/-->
                </p:toolbarGroup>
            </p:toolbar>
                        
            <p:dataTable var="branchcfg" value="#{branchcfgBean.branchcfgs}" id="dtBranchcfgs"
                         selection="#{branchcfgBean.selectedData}" selectionMode="single" 
                         rowKey="#{branchcfg.branchId}" 
                         paginator="true" rows="10" paginatorPosition="bottom" 
                         paginatorTemplate="#{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15,30">
                
                <p:column style="width:auto">
                    <f:facet name="header">#{bundle.branch}</f:facet>
                    <h:outputText value="#{branchcfgBean.getBranchName(branchcfg.branchId)}" />
                </p:column>
                
                <p:column style="width:auto">
                    <f:facet name="header">#{bundle.savbank}</f:facet>
                    <h:outputText value="#{branchcfgBean.getBankName(branchcfg.savBankId)}" />
                </p:column>
                
                <p:column style="width:auto">
                    <f:facet name="header">#{bundle.depbank}</f:facet>
                    <h:outputText value="#{branchcfgBean.getBankName(branchcfg.depBankId)}" />
                </p:column>
                                
            </p:dataTable>
          
            <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                    header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelBranchcfg">  
                <p:commandButton value="#{bundle.btnYes}" update="dtBranchcfgs" 
                                 oncomplete="handleDeleteRequest(xhr, status, args)"  
                    actionListener="#{branchcfgBean.delete()}" />  
                <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelBranchcfg.hide()" type="button" />   
            </p:confirmDialog> 

            <p:dialog header="#{bundle.branchcfg}" widgetVar="dlgBranchcfg" closable="true"
                      dynamic="true" >
                <p:ajax event="close" listener="#{branchcfgBean.handleClose}"/>
                <h:panelGrid id="displayBranchcfg" columns="2" styleClass="addELIT">
                    
                    <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.branch}" />
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{branchcfgBean.selectedData != null}">
                        <p:selectOneMenu value="#{branchcfgBean.selectedData.branchId}" id="branchcfgBranchId0" label="#{bundle.branch}" 
                            requiredMessage="#{bundle.branch} #{bundle.requiredInput}" required="true" >
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{branchcfgBean.avbBranchs}" />
                            <p:ajax update="msgbranchcfgBranchId0" />  
                        </p:selectOneMenu>
                        <p:message id="msgbranchcfgBranchId0" for="branchcfgBranchId0" display="icon" />
                    </h:panelGrid>
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{branchcfgBean.insertedData != null}">
                        <p:selectOneMenu value="#{branchcfgBean.insertedData.branchId}" id="branchcfgBranchId1" label="#{bundle.branch}" 
                            requiredMessage="#{bundle.branch} #{bundle.requiredInput}" required="true" >
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{branchcfgBean.avbBranchs}" />
                            <p:ajax update="msgbranchcfgBranchId1" />  
                        </p:selectOneMenu>
                        <p:message id="msgbranchcfgBranchId1" for="branchcfgBranchId1" display="icon" />
                    </h:panelGrid>
                    
                    
                    <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.savbank}" />
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{branchcfgBean.selectedData != null}">
                        <p:selectOneMenu value="#{branchcfgBean.selectedData.savBankId}" id="branchcfgsavbank0" label="#{bundle.savbank}" 
                                         requiredMessage="#{bundle.savbank} #{bundle.requiredInput}" required="true" >
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{branchcfgBean.avbBank}" />
                            <p:ajax update="msgbranchcfgsavbank0" />  
                        </p:selectOneMenu>
                        <p:message id="msgbranchcfgsavbank0" for="branchcfgsavbank0" display="icon" />
                    </h:panelGrid>
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{branchcfgBean.insertedData != null}">
                        <p:selectOneMenu value="#{branchcfgBean.insertedData.savBankId}" id="branchcfgsavbank1" label="#{bundle.savbank}" 
                                         requiredMessage="#{bundle.savbank} #{bundle.requiredInput}" required="true" >
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{branchcfgBean.avbBank}" />
                            <p:ajax update="msgbranchcfgsavbank1" />  
                        </p:selectOneMenu>
                        <p:message id="msgbranchcfgsavbank1" for="branchcfgsavbank1" display="icon" />
                    </h:panelGrid>
                    
                    
                    <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.depbank}" />
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{branchcfgBean.selectedData != null}">
                        <p:selectOneMenu value="#{branchcfgBean.selectedData.depBankId}" id="branchcfgdepbank0" label="#{bundle.depbank}" 
                                         requiredMessage="#{bundle.depbank} #{bundle.requiredInput}" required="true" >
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{branchcfgBean.avbBank}" />
                            <p:ajax update="msgbranchcfgdepbank0" />  
                        </p:selectOneMenu>
                        <p:message id="msgbranchcfgdepbank0" for="branchcfgdepbank0" display="icon" />
                    </h:panelGrid>
                    
                    <h:panelGrid columns="2" cellpadding="0" cellspacing="0" rendered="#{branchcfgBean.insertedData != null}">
                        <p:selectOneMenu value="#{branchcfgBean.insertedData.depBankId}" id="branchcfgdepbank1" label="#{bundle.depbank}" 
                                         requiredMessage="#{bundle.depbank} #{bundle.requiredInput}" required="true" >
                            <f:selectItem itemLabel="" itemValue="" />
                            <f:selectItems value="#{branchcfgBean.avbBank}" />
                            <p:ajax update="msgbranchcfgdepbank1" />  
                        </p:selectOneMenu>
                        <p:message id="msgbranchcfgdepbank1" for="branchcfgdepbank1" display="icon" />
                    </h:panelGrid>
                    
                </h:panelGrid>
                
                <h:panelGrid columns="2" cellpadding="1" styleClass="pComBtnSTDR">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk"  actionListener="#{branchcfgBean.save()}"
                                         update="dtBranchcfgs" widgetVar="cmdBranchcfg"
                            oncomplete="handleSaveRequest(xhr, status, args)"/>
                        <p:commandButton  value="#{bundle.btnClose}" oncomplete="dlgBranchcfg.hide()" icon="ui-icon-document"/>
                    </f:facet>
                </h:panelGrid>
            </p:dialog> 
        </h:form>
        </ui:composition>    
    </h:body>
</html>
